package com.ftg.mall.base.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;


/**
 * @author kangjx
 * @date 2022/12/26
 */
@Component
public class RedisUtil {


    RedisTemplate<String,String> redisTemplate;

    @Autowired
    public void setRedisTemplate(RedisTemplate<String,String> redisTemplate){
        this.redisTemplate = redisTemplate;
    }

    /**
     * 对字符串的操作封装
     */
    public boolean stringSet(String key,String value,long ltime){
        redisTemplate.opsForValue().set(key,value,ltime, TimeUnit.SECONDS);
        return true;
    }



    /**
     * 对字符串的操作封装
     */
    public String stringGet(String key){
        return redisTemplate.opsForValue().get(key);
    }

}
